/**
 * 配置文件
 * 包含数据库连接信息、JWT密钥和其他全局配置
 */

// 尝试加载dotenv
try {
    require('dotenv').config();
} catch (error) {
    console.log('dotenv not loaded, using default values');
}

// 数据库配置
const database = {
    host: 'localhost',
    port: 27017,
    name: '4399games',
    uri: process.env.MONGO_URI || 'mongodb://localhost:27017/game4399'
};

// JWT配置
const jwt = {
    secret: process.env.JWT_SECRET || 'your_jwt_secret',
    expiresIn: process.env.JWT_EXPIRE || '30d',
    cookieExpire: parseInt(process.env.JWT_COOKIE_EXPIRE) || 30
};

// 服务器配置
const server = {
    port: process.env.PORT || 3000,
    corsOrigin: process.env.CORS_ORIGIN || 'http://localhost:8000'
};

// 文件上传配置
const upload = {
    gameFilePath: 'uploads/games',
    thumbnailPath: 'uploads/thumbnails',
    maxGameSize: 100 * 1024 * 1024, // 100MB
    maxThumbnailSize: 5 * 1024 * 1024, // 5MB
    allowedGameTypes: ['.zip', '.rar', '.html', '.exe', '.swf'],
    allowedThumbnailTypes: ['.jpg', '.jpeg', '.png', '.gif', '.webp']
};

module.exports = {
    database,
    server,
    jwt,
    upload
}; 